#!/bin/bash
err() { echo Error. $@ not found.; exit 1; }

[ -z `which sam-ba` ] && err sam-ba
[ ! -c /dev/ttyUSB1 ] && err /dev/ttyUSB1
[ ! -f /opt/9263/deploy/rootfs.bin ] && err /opt/9263/deploy/rootfs.bin
[ ! -f deployrootfs.tcl ] && err deployrootfs.tcl
cp deployrootfs.tcl /opt/9263/deploy
cd /opt/9263/deploy
sam-ba /dev/ttyUSB1 AT91SAM9263-EK deployrootfs.tcl
rm deployrootfs.tcl -f
